/*
 * Copyright [2011] [Ambud Sharma/ODep Monitor]

   Licensed under the Apache License, Version 2.0 (the "License");

   you may not use this file except in compliance with the License.

   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software

   distributed under the License is distributed on an "AS IS" BASIS,

   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

   See the License for the specific language governing permissions and

   limitations under the License.
 */
package edu.uwsp.orion.odepm.Login.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;


public class Login implements EntryPoint {
	
	public void onModuleLoad() {
		RootPanel rp=RootPanel.get("mainpanel");
		rp.getElement().getStyle().setPosition(Position.RELATIVE);
		//rp.setStyleName("background_main");
		Window.alert("hello");
//		
//		VerticalPanel verticalPanel = new VerticalPanel();
//		verticalPanel.setStyleName("background_main");
//		rp.add(verticalPanel, 0, 0);
//		verticalPanel.setSize("1000px", "754px");
//		
//		AbsolutePanel apHeader = new AbsolutePanel();
//		apHeader.setStyleName("background_main");
//		verticalPanel.add(apHeader);
//		apHeader.setHeight("82px");
//		
//		Image image_1 = new Image("images/HeaderMonitor.png");
//		apHeader.add(image_1, 0, 0);
//		image_1.setSize("1000px", "82px");
//		
//		AbsolutePanel apBody = new AbsolutePanel();
//		apBody.setStyleName("background_main");
//		verticalPanel.add(apBody);
//		apBody.setHeight("672px");
//		
//		com.gwtext.client.widgets.form.FormPanel frmpnlOdepMonitorLogin = new com.gwtext.client.widgets.form.FormPanel();
//		FormLayout formLayout = (FormLayout) frmpnlOdepMonitorLogin.getLayout();
//		//formLayout.setLabelAlign(com.gwtext.client.core.Position.CENTER);
//		
//		final TextField tFUsername = new TextField("Username", "username", 100);
//		frmpnlOdepMonitorLogin.add(tFUsername);
//		frmpnlOdepMonitorLogin.setTitle("ODep Monitor Login");
//		frmpnlOdepMonitorLogin.setLabelAlign(com.gwtext.client.core.Position.CENTER);
//		frmpnlOdepMonitorLogin.setPaddings(5);
//		
//		final TextField tFPassword = new TextField("Password", "password", 100);
//		tFPassword.setPassword(true);
//		frmpnlOdepMonitorLogin.add(tFPassword);
//		frmpnlOdepMonitorLogin.setFrame(true);
//		
//		com.gwtext.client.widgets.Button btnLogin = new com.gwtext.client.widgets.Button("Login");
//		btnLogin.setTooltip("Login to ODep Monitor");
//		btnLogin.setMinWidth(30);		
//		frmpnlOdepMonitorLogin.add(btnLogin);	
//		apBody.add(frmpnlOdepMonitorLogin, 401, 233);
//		frmpnlOdepMonitorLogin.setSize("265px", "125px");		
//		
//		btnLogin.addListener(new ButtonListenerAdapter() {
//			@Override
//			public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
//				LoginServiceAsync asyncLogin=GWT.create(LoginService.class);
//				asyncLogin.verifyLogin(tFUsername.getText(), tFPassword.getText(), new AsyncCallback<Boolean>() {
//					
//					@Override
//					public void onSuccess(Boolean result) {
//						Date time=new Date();
//						long currentTime=time.getTime()+(60*1000*30);
//						time.setTime(currentTime);
//						Cookies.setCookie("authenticated_odep", "true", time);
//						Window.Location.assign("/ODepMonitor.html");						
//					}
//					
//					@Override
//					public void onFailure(Throwable caught) {
//						Window.alert("failed to reach server!");
//					}
//				});
//			}
//		});		

	}
}
